package cn.tedu.start.controller.admincontroller;


import cn.tedu.commons.response.JsonResult;
import cn.tedu.pojo.admin.dto.AdminLoginDTO;
import cn.tedu.service.adminService.Admin_LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 管理员表 前端控制器
 * </p>
 *
 * @author tedu.cn
 * @since 2021-12-02
 */

@RestController
@RequestMapping("/admin")
public class Admin_LoginController
{
/**
 * 新增管理员
 */
@Autowired
private Admin_LoginService admin_loginService;

@PostMapping("/add")
public JsonResult addNewAdmin(@RequestBody AdminLoginDTO admin_loginDTO) {
        return admin_loginService.addNewAdmin(admin_loginDTO);


        }

@PostMapping("/updatename")
public JsonResult<Void> updataAdmin(@RequestBody AdminLoginDTO admin_loginDTO) {
        System.out.println(admin_loginDTO);
        admin_loginService.updateByAdminname(admin_loginDTO.getAdminName(), admin_loginDTO.getId());
        return JsonResult.ok();
        }

@PostMapping("/updatepassword")
public JsonResult updateByPassword(@RequestBody AdminLoginDTO admin_loginDTO) {
        admin_loginService.updateByPassword(admin_loginDTO.getAdminPassword(), admin_loginDTO.getId());
        return JsonResult.ok();

        }
@GetMapping("/sellAdmin")
public JsonResult sellAdmin(@RequestBody AdminLoginDTO admin_loginDTO) {
        admin_loginService.sellAdmin(admin_loginDTO);
        return JsonResult.ok();
        }
        }
